//---------------------------------------------------------------------------
#ifndef uComposantH
#define uComposantH
//---------------------------------------------------------------------------
#include "uRtf.h"
enum Type_CoinSelectionne {
    sel_Haut         = 0x0001,
    sel_VMilieu      = 0x0002,
    sel_Bas          = 0x0004,
    sel_Gauche       = 0x0010,
    sel_HMilieu      = 0x0020,
    sel_Droit        = 0x0040,

    sel_HautGauche   = sel_Haut | sel_Gauche,
    sel_HautMilieu   = sel_Haut | sel_HMilieu,
    sel_HautDroit    = sel_Haut | sel_Droit,
    sel_MilieuGauche = sel_VMilieu | sel_Gauche,
    sel_MilieuDroit  = sel_VMilieu | sel_Droit,
    sel_BasGauche    = sel_Bas | sel_Gauche,
    sel_BasMilieu    = sel_Bas | sel_HMilieu,
    sel_BasDroit     = sel_Bas | sel_Droit,
//    sel_Max = sel_BasDroit,
    sel_Aucun = 0x0000,
};
/*enum Type_Composant {
    cp_Rectangle=1,
    cp_Ellipse,
    cp_Texte,
    cp_Image,
    cp_Fleche,
    cp_Champ,
    cp_Tableau,
    cp_NbTypeCp = 7
};*/



enum Carac_Composant {
    car_Base            = 0x00000000,
    car_BordsCanDiff    = 0x00000001,
    car_Ellipse         = 0x00000002,
    car_Courbure        = 0x00000004,
    car_Texte           = 0x00000008,
    car_Image           = 0x00000010,
    car_Fleche          = 0x00000020,
    car_Champ           = 0x00000040,
    car_Tableau         = 0x00000080,
    car_Name            = 0x40000000,
    car_Graphic         = 0x80000000,

    car_MskTypeCp       = car_Base | car_BordsCanDiff | car_Ellipse | car_Courbure
                        | car_Texte | car_Image | car_Fleche | car_Champ | car_Tableau
                        | car_Name | car_Graphic,

    Carac_Rectangle       = car_Courbure | car_BordsCanDiff | car_Graphic,
    Carac_Ellipse         = car_Ellipse,
    Carac_Texte           = car_Courbure | car_BordsCanDiff | car_Texte,
    Carac_Image           = car_Graphic  | car_BordsCanDiff | car_Image,
    Carac_Fleche          = car_Fleche,
    Carac_Champ           = Carac_Texte | car_Champ | car_Name,
    Carac_Tableau         = Carac_Rectangle | car_Tableau | car_Name,
    cp_NbTypeCp           = 7,

    car_LargeurStd      = 0x00010000,
    car_LargeurColonne  = 0x00020000,
    car_LargeurEtat     = 0x00040000,
    car_ColleGauche     = 0x00080000,
    car_ColleDroite     = 0x01000000,
    car_MskLargeur      = car_LargeurStd | car_LargeurColonne | car_LargeurEtat | car_ColleGauche | car_ColleDroite,

    car_HauteurStd      = 0x00100000,
    car_HauteurBande    = 0x00200000,
    car_HauteurLigne    = 0x00400000,
    car_ColleHaut       = 0x00800000,
    car_ColleBas        = 0x02000000,
    car_MskHauteur      = car_HauteurStd | car_HauteurBande |  car_HauteurLigne | car_ColleHaut | car_ColleBas,

    car_All             = 0xffffffff,
};

enum TypesComposants{
    ETAT_Cp_Champs_Nommes,
    ETAT_Cp_Tableaux_Nommes,
    ETAT_Cp_Textes_Saisis,
    ETAT_Cp_MAX = ETAT_Cp_Textes_Saisis
};




/*#define Carac_Rectangle  ((Carac_Composant)(car_Courbure | car_BordsCanDiff | car_Graphic))
#define Carac_Ellipse    ((Carac_Composant)(car_Ellipse))
#define Carac_Texte      ((Carac_Composant)(car_Courbure | car_BordsCanDiff | car_Texte))
#define Carac_Image      ((Carac_Composant)(car_Graphic  | car_BordsCanDiff | car_Image))
#define Carac_Fleche     ((Carac_Composant)(car_Fleche))
#define Carac_Champ      ((Carac_Composant)(Carac_Texte | car_Champ | car_Name))
#define Carac_Tableau    ((Carac_Composant)(Carac_Rectangle | car_Tableau | car_Name))*/

//---------------------------------------------------------------------------
class TComposant;
//---------------------------------------------------------------------------
class ETATAPI TListOfComposants : public TList
{
private :
    HRGN         m_hOld;
    TBande*      m_BandeOwner;
    bool         m_bCpExtensible, m_bTextesExtensible;
    TComposant* __fastcall GetItem( int Index)const;
    TDocument*  __fastcall  GetDocOwner()const;
    TEtat*      __fastcall  GetEtatOwner()const;

public  :
    __fastcall TListOfComposants( TBande *Bande, TFlux *f = NULL);
    virtual __fastcall ~TListOfComposants();

    void __fastcall Draw( );
    virtual void __fastcall Calculs( );
    void __fastcall DrawCpExtensibles( );
    void __fastcall Enregistre( TFlux *f);

    TComposant* __fastcall Add( Carac_Composant Type, const TCoordonnee &X, const TCoordonnee &Y);
    TComposant* __fastcall Add( Carac_Composant wType, TFlux *f);
    TComposant* __fastcall Add( TComposant* Cp);
    void        __fastcall Delete( TComposant* Cp);
    int         __fastcall IndexOf(const TComposant* Item)const { return TList::IndexOf( (void*)Item); };

    void __fastcall MettreEnAvantPlan( TComposant* Cp);
    void __fastcall MettreEnArrierePlan( TComposant* Cp);
    __property TComposant* Items[int Index] = {read=GetItem};
    __property TDocument* DocOwner   = {read=GetDocOwner };
    __property TEtat*     EtatOwner  = {read=GetEtatOwner};
    __property TBande*    BandeOwner = {read=m_BandeOwner};
    __property bool       bTexteExtensible = {write= m_bTextesExtensible}; 


    void        __fastcall GetComposantsIn( TList* ListeCp, const TCoorRect &rSelection, const TBande* BandeQuiDemande, bool bSelEntier)const;
    TComposant* __fastcall GetComposant( const TCoordonnee &X, const TCoordonnee &Y, Type_CoinSelectionne &CoinCourant)const;
    TComposant* __fastcall GetComposant( const AnsiString &s)const;
    void        __fastcall GetComposants( enum TypesComposants, TStrings *LstCp)const;
    void        __fastcall InvalideComposantsAttacheA( const AnsiString &ChpAttache);
    void        __fastcall NettoieComposantsAttacheA( const AnsiString &ChpAttache);
    void        __fastcall GetCpCalc( TList* ListeCpCalcCol, TList* ListeCpCalcLigne, TList* LstCpExtensibles, bool &bCpNbPages)const;
    TComposant* __fastcall GetPrecedentSuivant( bool bPrec, const TComposant* Cp)const;
    TComposant* __fastcall GetChampEnDessous( const TComposant* CpRef)const;

    void        __fastcall Nettoie( );
    void        __fastcall AppliqueStyles( );
    void        __fastcall InitValeurs( );
    bool        __fastcall WantedHeight( TCoordonnee &HeightMin, TCoordonnee &HeightMax, bool &TiensElleEstEnCours)const;
    TCpChamp*   __fastcall GetCpChamp( const AnsiString &s)const;
    TCpTableau* __fastcall GetCpTableau( const AnsiString &s)const;
    void        __fastcall DeplaceTout( const TCoordonnee &c);
    bool        __fastcall CpExtensiblesFinis();
};

//---------------------------------------------------------------------------
class ETATAPI TComposant : public TMyObject
{
    friend class TListOfComposants;
protected:
    TCoorPoint          m_PointHtG;
    TYPE_BANDE          m_eTypeBandeBs;
    WORD                m_wNiveauBs;
    TCoorPoint          m_PointBsD;

    Carac_Composant  m_CaracCp;
//    WORD             m_eTypeComposant;

    TPenStyle    m_PenStyle;
    float        m_PenWidthGauche;
    float        m_PenWidthHaut;
    float        m_PenWidthDroit;
    float        m_PenWidthBas;
    bool         m_MoitieGauche;
    bool         m_MoitieDroit;

    bool         m_bForceBrushStyle;
    TBrushStyle  m_BrushStyle;
    enum TColor  m_BrushColor;
    TListOfComposants*  m_ListCpOwner;
    bool         m_VisibleCalc, m_bVisible;
    AnsiString   m_Style;


    virtual bool   __fastcall GetVisible( )const  { return Glob->bConception? true:(((m_DansUneColonneViree==-1) || !m_DansUneColonneViree) && m_bVisible && m_VisibleCalc);}

private :
    short               m_NumColonne;
    short               m_NumLigne;
    AnsiString          m_NomChpHorzAssocie;
    AnsiString          m_NomChpVertAssocie;

    short               m_DansUneColonneViree;

    TColor              m_PenColor;

    HRGN                m_hSel;

    TBande             *m_BdBas;

    bool            m_bSelected;
    void __fastcall SetSelected( bool b);

    void __fastcall SetNumColonne( short n)                 {if( n     != m_NumColonne)    { m_NumColonne     = n; m_GetTrueCoorHtG.x.Twips = -1; Modifie();} };
    void __fastcall SetNumLigne( short n)                   {if( n     != m_NumLigne)      { m_NumLigne     = n;   m_GetTrueCoorHtG.y.Twips = -1; Modifie();} };
    void __fastcall SetNomChpHorzAssocie( const AnsiString &s)  {if( s     != m_NomChpHorzAssocie) { m_NomChpHorzAssocie = s;  m_GetTrueCoorHtG.x.Twips = -1; Modifie();} };
    void __fastcall SetNomChpVertAssocie( const AnsiString &s)  {if( s     != m_NomChpVertAssocie) { m_NomChpVertAssocie = s;  m_GetTrueCoorHtG.y.Twips = -1; Modifie();} };
    void __fastcall SetStyle( const AnsiString &s);

    void __fastcall SetPenStyle( TPenStyle ps)              {if( ps    != m_PenStyle)      { m_PenStyle       = ps;    Modifie();} };
    TColor __fastcall GetPenColor( )                        {if( m_PenColor == -1) return DocOwner->ColorDefaut; else return m_PenColor;};
    void __fastcall SetPenColor( TColor color);
    void __fastcall SetPenWidthGauche( float w) {if( w     != m_PenWidthGauche){ m_PenWidthGauche = w;     Modifie();} };
    void __fastcall SetPenWidthHaut( float w)   {if( w     != m_PenWidthHaut)  { m_PenWidthHaut   = w;     Modifie();} };
    void __fastcall SetPenWidthDroit( float w)  {if( w     != m_PenWidthDroit) { m_PenWidthDroit  = w;     Modifie();} };
    void __fastcall SetPenWidthBas( float w)    {if( w     != m_PenWidthBas)   { m_PenWidthBas    = w;     Modifie();} };
    void __fastcall SetMoitieGauche( bool b)    {if( b     != m_MoitieGauche)  { m_MoitieGauche   = b;     Modifie();} };
    void __fastcall SetMoitieDroit( bool b)     {if( b     != m_MoitieDroit)   { m_MoitieDroit    = b;     Modifie();} };

    void __fastcall SetBrushStyle( TBrushStyle bs)    {if( bs    != m_BrushStyle)    { m_BrushStyle       = bs;    Modifie();} };
    void __fastcall SetBrushColor( TColor color)      {if( color != m_BrushColor)    { m_BrushColor       = color; Modifie();} };
    void __fastcall _SetBounds( const TCoordonnee &Left, const TCoordonnee &Top, const TCoordonnee &Right, const TCoordonnee &Bottom);
    virtual HWND __fastcall GetEditing()              { return( NULL);}

    TDocument* __fastcall GetDocOwner()const;
    TEtat*     __fastcall GetEtatOwner()const;
    TBande*    __fastcall GetBandeOwner()const;
    TBande*    __fastcall GetBandeBs()const;
    TCoordonnee  __fastcall GetLargeur()const;
    TCoordonnee  __fastcall GetHauteur()const;
    TCoordonnee  __fastcall GetGauche()const;
    TCoordonnee  __fastcall GetHaut()const;
    TCoordonnee  __fastcall GetDroit()const;
    TCoordonnee  __fastcall GetBas()const;
    TCoordonnee  __fastcall GetGaucheReel()const;
    TCoordonnee  __fastcall GetHautReel()const;
    TCoordonnee  __fastcall GetDroitReel()const;
    TCoordonnee  __fastcall GetBasReel()const;
    void __fastcall SetLargeur( const TCoordonnee &l);
    void __fastcall SetHauteur( const TCoordonnee &h);
    void __fastcall SetLstOwner( TListOfComposants *LstCp);
    void __fastcall SetCaracCp( Carac_Composant CaracCp);
public :
    __fastcall TComposant( TListOfComposants *ListCp, TFlux *f, Carac_Composant CaracCp);
    __fastcall TComposant( TListOfComposants *ListCp, const TCoordonnee &X, const TCoordonnee &Y, Carac_Composant CaracCp);
    virtual __fastcall ~TComposant();
    virtual void __fastcall Enregistre( TFlux *f)const;
    virtual void __fastcall Calculs( );

            void __fastcall InvalidateSelect( );
            void __fastcall DrawSelect( TColor cl);
            void __fastcall CouleurEfface( );
            void __fastcall CouleurDraw( );
    virtual void __fastcall Draw( ){ Dessine(NULL);};
    virtual void __fastcall Dessine( const TBande* BandeADessiner);
//    virtual void __fastcall Efface( )=0;
    virtual void __fastcall OnBeginEdit( TWinControl *aOwner, int OffsetX, int OffsetY){};
    virtual void __fastcall OnEndEdit( ){};
    __property   HWND       Editing  = { read=GetEditing};
            void __fastcall Invalidate( const TCoordonnee *Left=NULL, const TCoordonnee *Top=NULL, const TCoordonnee *Right=NULL, const TCoordonnee *Bottom=NULL);
    virtual void __fastcall InvalidateR( const TCoorRect &Rc)=0;

            bool      __fastcall DansUneColonneViree( )const;
    virtual void      __fastcall GetTrueCoordonnees( TCoorPoint &ptHtG, TCoorPoint &ptBsD, const TBande* BandeADessiner=NULL)const;
    virtual TCoorRect __fastcall GetTrueCoordonnees( TCoorRect &Rc, const TBande* BandeADessiner=NULL)const;
            bool      __fastcall IsHautInBande( const TBande* b)const;
            bool      __fastcall IsBasInBande( const TBande* b)const;
            bool      __fastcall IsComposantAttacheA( const AnsiString &ChpAttache);
            // le tout est en coordonnes du bitmap
            void __fastcall SetGauche( const TCoordonnee &Left);
            void __fastcall SetHaut( const TCoordonnee &Top);
            void __fastcall SetDroit( const TCoordonnee &Right);
            void __fastcall SetBas( const TCoordonnee &Bottom);
            void __fastcall SetPointHtG( const TCoordonnee &Left, const TCoordonnee &Top);
            void __fastcall SetPointHtD( const TCoordonnee &Right, const TCoordonnee &Top);
            void __fastcall SetPointBsG( const TCoordonnee &Left, const TCoordonnee &Bottom);
            void __fastcall SetPointBsD( const TCoordonnee &Right, const TCoordonnee &Bottom);
            void __fastcall SetBounds( const TCoordonnee &Left, const TCoordonnee &Top, const TCoordonnee &Right, const TCoordonnee &Bottom);
            TCoorRect& __fastcall GetLimites( TCoorRect &r)const;
            HRGN __fastcall GetRgnSel( );
            void __fastcall ClipAndCombineWith( HRGN h, const TBande* BandeADessiner=NULL);
//    TCoorRect* __fastcall GetRectSel( );
            void __fastcall ControleApresSuppression( const TBande *b);

//    __property   WORD        TypeComposant = { read=m_eTypeComposant};

    __property   bool             Selected      = { read=m_bSelected,     write=SetSelected};

//    __property   TCoorPoint       PointHtG      = { read=m_PointHtG };
    __property   TDocument       *DocOwner      = { read=GetDocOwner  };
    __property   TEtat           *EtatOwner     = { read=GetEtatOwner  };
    __property   TBande          *BandeOwner    = { read=GetBandeOwner };
    __property   TBande          *BandeHt       = { read=BandeOwner };
    __property   TListOfComposants *ListCpOwner = { read=m_ListCpOwner };
    __property   TCoorPoint       _PointBsD     = { read=m_PointBsD };
    __property   TBande          *BandeBs       = { read=GetBandeBs };
    __property   Carac_Composant  CaracCp       = { read=m_CaracCp,  write=SetCaracCp};
    __property   TCoordonnee      Largeur       = { read=GetLargeur, write=SetLargeur};
    __property   TCoordonnee      Hauteur       = { read=GetHauteur, write=SetHauteur};
    __property   TCoordonnee      Gauche        = { read=GetGauche,  write=SetGauche};
    __property   TCoordonnee      Haut          = { read=GetHaut,    write=SetHaut};
    __property   TCoordonnee      Droit         = { read=GetDroit,   write=SetDroit};
    __property   TCoordonnee      Bas           = { read=GetBas,     write=SetBas};
    __property   TCoordonnee      GaucheReel    = { read=GetGaucheReel};
    __property   TCoordonnee      HautReel      = { read=GetHautReel};
    __property   TCoordonnee      DroitReel     = { read=GetDroitReel};
    __property   TCoordonnee      BasReel       = { read=GetBasReel};
    __property   short            NumColonne    = { read=m_NumColonne, write=SetNumColonne};
    __property   short            NumLigne      = { read=m_NumLigne,   write=SetNumLigne};
    __property   AnsiString       NomChpHorzAssocie = { read=m_NomChpHorzAssocie, write=SetNomChpHorzAssocie};
    __property   AnsiString       NomChpVertAssocie = { read=m_NomChpVertAssocie, write=SetNomChpVertAssocie};
    __property   bool             VisibleCalc   = { read=m_VisibleCalc};
    __property   AnsiString       Style         = { read=m_Style, write=SetStyle};


    __property   TPenStyle   PenStyle       = { read=m_PenStyle,       write=SetPenStyle };
    __property   TColor      PenColor       = { read=GetPenColor,      write=SetPenColor };
    __property   float PenWidthGauche = { read=m_PenWidthGauche, write=SetPenWidthGauche };
    __property   float PenWidthHaut   = { read=m_PenWidthHaut,   write=SetPenWidthHaut };
    __property   float PenWidthDroit  = { read=m_PenWidthDroit,  write=SetPenWidthDroit };
    __property   float PenWidthBas    = { read=m_PenWidthBas,    write=SetPenWidthBas };
    __property   bool MoitieGauche  = { read=m_MoitieGauche,   write=SetMoitieGauche };
    __property   bool MoitieDroit   = { read=m_MoitieDroit,    write=SetMoitieDroit };

    __property   bool        ForceBrushStyle = { read=m_bForceBrushStyle,write=m_bForceBrushStyle};
    __property   TBrushStyle BrushStyle      = { read=m_BrushStyle,      write=SetBrushStyle };
    __property   TColor      BrushColor      = { read=m_BrushColor,      write=SetBrushColor };


    virtual void __fastcall Nettoie( );
            bool __fastcall GetStyle( EICStyle *&Style);
    virtual void __fastcall AppliqueStyle( EICStyle *Style=NULL);
    TComposant* __fastcall  GetPrecedentSuivant( bool bPrec)const;
    TComposant* __fastcall  GetChampEnDessous( )const;

    // variables temporaires servant d'optimisations
protected:
    mutable TCoordonnee  m_DecalInterneGauche, m_DecalInterneDroite, m_DecalInterneBas;
    mutable TCoordonnee  m_LargTrueCoor;
private:
    mutable const TBande *m_bdDess;
    mutable TCoordonnee  m_bdHautTop;
    mutable TCoorPoint   m_GetTrueCoorHtG,  m_GetTrueCoorBsD;
};

//---------------------------------------------------------------------------
class ETATAPI TCpRectangle : public TComposant
{
private :
    TCoordonnee      m_RayonCourbure;
    void __fastcall SetRayonCourbure( const TCoordonnee &r)  {if( r != m_RayonCourbure) { m_RayonCourbure = r; Modifie( );} };
public :
    __fastcall TCpRectangle( TListOfComposants *ListCp, TFlux *f, Carac_Composant CaracCp = Carac_Rectangle);
    __fastcall TCpRectangle( TListOfComposants *ListCp, const TCoordonnee &X, const TCoordonnee &Y, Carac_Composant CaracCp = Carac_Rectangle);
    virtual void __fastcall Enregistre( TFlux *f)const;
//    virtual void __fastcall Efface( )  { TComposant::CouleurEfface(); Dessine();};
    virtual void __fastcall Dessine( const TBande* b);
    virtual void __fastcall InvalidateR( const TCoorRect &Rc);
    __property   TCoordonnee      RayonCourbure = { read=m_RayonCourbure, write=SetRayonCourbure };
};

//---------------------------------------------------------------------------
class ETATAPI TCpEllipse : public TComposant
{
private :

public :
    __fastcall TCpEllipse( TListOfComposants *ListCp, TFlux *f, Carac_Composant CaracCp = Carac_Ellipse);
    __fastcall TCpEllipse( TListOfComposants *ListCp, const TCoordonnee &X, const TCoordonnee &Y, Carac_Composant CaracCp = Carac_Ellipse);
//    virtual void __fastcall Efface( )  { TComposant::CouleurEfface(); Dessine();};
    virtual void __fastcall Dessine( const TBande* b);
    virtual void __fastcall InvalidateR( const TCoorRect &Rc);
};


//---------------------------------------------------------------------------
class ETATAPI TCpTexte : public TCpRectangle
{
private :
    typedef TCpRectangle inherited;
    bool          m_SoulignePointille;
    EICFont      *m_Font;
    TStringList  *m_LstTexte;
    byte          m_IdMiseEnForme;
    TCoordonnee   m_Retrait;
    AnsiString    m_Commentaire;
    EICFont      *m_FontCommentaire;
    TCoordonnee   m_EspaceTexte;

    EICFont* __fastcall GetFont( )const                       {if( m_Font) return m_Font; else return DocOwner->FontDefaut; };
    void   __fastcall SetFont( const EICFont *f);
    void   __fastcall SetPresentation( Text_Presentation p);
    void   __fastcall SetOrientation( int o)                  {if( o != m_Orientation)       { m_Orientation = o;       Modifie( );} };
    void   __fastcall SetSoulignePointille( bool b)           {if( b != m_SoulignePointille) { m_SoulignePointille = b; Modifie( );} };
    HWND   __fastcall GetEditing()                            { return( m_ed? m_ed->Handle: NULL);}
    void   __fastcall SetFormat( Text_Format f)               {if( f != m_Format)        { DetruitpvFormat(); m_Format = f;        Modifie( );} };
    void   __fastcall SetpvFormat( TObject* pv);
    TObject*   __fastcall GetpvFormat( )const;
    void   __fastcall DetruitpvFormat( );
    EICFont* __fastcall GetFontCommentaire( )const            {if( m_FontCommentaire) return m_FontCommentaire; else return DocOwner->FontDefaut; };
    void   __fastcall SetFontCommentaire( const EICFont *f);
    void   __fastcall SetPresentationCommentaire( Text_Presentation pc);
    long m_nLastCharPrint;

protected :
    TMemo              *m_ed;
    Text_Presentation   m_fPresentation;
    Text_Presentation   m_fPresentationCommentaire;    
    int                 m_Orientation;
    Text_Format         m_Format;
    TObject            *m_pvFormat;

    void   __fastcall SetTexteLangue( byte IdLangue, int index, const AnsiString &pTexte);
    void   __fastcall SetTexte( const AnsiString &pTexte);
    void       __fastcall SetAllTextes( AnsiString &s)const;
    AnsiString __fastcall GetAllTextes()const ;
    AnsiString __fastcall GetTexteLangue( byte IdLangue, int index=1)const;
    AnsiString __fastcall GetTexteSaisi( )const                 { return GetTexteLangue( DocOwner->Langue); };
    virtual AnsiString __fastcall GetTexte( )const            {return GetTexteSaisi(); };
    void       __fastcall SetRetrait( const TCoordonnee &ret) { if( ret != m_Retrait) { m_Retrait = ret; Modifie();}};
    bool       __fastcall GetTrueCoordonneesInternes( bool bAvecDecalInterne, TCoorRect &CoorRc, const TBande* BandeADessiner=NULL)const;
    void       __fastcall SetCommentaire( const AnsiString &pCommentaire) { if (pCommentaire != m_Commentaire) {m_Commentaire = pCommentaire;Modifie();}};
    void       __fastcall SetEspaceTexte( const TCoordonnee &Espace) { if( Espace != m_EspaceTexte) { m_EspaceTexte= Espace; Modifie();}};
public    :
    virtual __fastcall ~TCpTexte( );
    __fastcall TCpTexte( TListOfComposants *ListCp, TFlux *f, Carac_Composant CaracCp = Carac_Texte);
    __fastcall TCpTexte( TListOfComposants *ListCp, const TCoordonnee &X, const TCoordonnee &Y, Carac_Composant CaracCp = Carac_Texte);

    virtual void      __fastcall Enregistre( TFlux *f)const;
    virtual void      __fastcall Dessine( const TBande* b);
    virtual void      __fastcall InvalidateR( const TCoorRect &Rc);
    virtual void      __fastcall Nettoie( );
    virtual void      __fastcall AppliqueStyle( EICStyle *Style=NULL);

    virtual TCoorRect __fastcall GetTrueCoordonnees( TCoorRect &Rc, const TBande* BandeADessiner=NULL)const{ return inherited::GetTrueCoordonnees( Rc, BandeADessiner);};
    virtual void      __fastcall GetTrueCoordonnees( TCoorPoint &ptHtG, TCoorPoint &ptBsD, const TBande* BandeADessiner=NULL)const;
    __property   AnsiString           Texte             = { read=GetTexteSaisi,       write=SetTexte};
    __property   AnsiString           AllTextes         = { read=GetAllTextes,        write=SetAllTextes};
    __property   AnsiString           TexteLangue[byte IdLangue]       = { read=GetTexteLangue,       write=SetTexteLangue, index = 1};
    __property   AnsiString           RealTexteLangue[byte IdLangue]   = { read=GetTexteLangue,       write=SetTexteLangue, index = 0};
    __property   EICFont*             Font              = { read=GetFont,             write=SetFont};
    __property   bool                 SoulignePointille = { read=m_SoulignePointille, write=SetSoulignePointille};
    __property   Text_Presentation    Presentation      = { read=m_fPresentation,     write=SetPresentation};
    __property   Text_Presentation    PresentationCommentaire          = { read=m_fPresentationCommentaire,  write=SetPresentationCommentaire};
    __property   int                  Orientation       = { read=m_Orientation,       write=SetOrientation};
    __property   Text_Format          Format            = { read=m_Format,            write=SetFormat};
    __property   TObject*             pvFormat          = { read=GetpvFormat,         write=SetpvFormat};
    __property   TObject*             pvFormat_Reel     = { read=m_pvFormat};
    __property   TCoordonnee          Retrait           = { read=m_Retrait,           write=SetRetrait};
    __property   AnsiString           Commentaire       = { read=m_Commentaire,       write=SetCommentaire};
    __property   EICFont*             FontCommentaire   = { read=GetFontCommentaire,  write=SetFontCommentaire};
    __property   TCoordonnee          EspaceTexte       = { read=m_EspaceTexte,       write=SetEspaceTexte};

    virtual void __fastcall OnBeginEdit( TWinControl *aOwner, int OffsetX, int OffsetY);
    virtual void __fastcall OnEndEdit( );
            void __fastcall EditKeyUp(TObject *Sender, WORD &Key, TShiftState Shift);
    __property   HWND       Editing  = { read=GetEditing};

    bool __fastcall WantedToChangeHeightOfBande( TCoordonnee &HauteurSuhaiteeMin, TCoordonnee &HauteurSuhaiteeMax, bool &TiensIlEstEnCours)const;
    __property   long  nLastCharPrint = { read= m_nLastCharPrint,write= m_nLastCharPrint};

    void __fastcall SupprimeLangue( byte IdLangue);
    void __fastcall AjouteLangue( );
    void __fastcall CreationFmtNum_Cur();
};
//---------------------------------------------------------------------------
enum Type_Calcul {
    tcalc_Info=0,
    tcalc_Colonne,
    tcalc_Ligne,
    tcalc_Max  = 3
};
enum Type_Calcul_Col {
    tCalcCol_Total=0,
    tCalcCol_Total_Page,
    tcalcCol_Max  = 2
};
class ETATAPI TCpChamp : public TCpTexte
{
private :
    TField          *m_Field;
    typedef TCpTexte inherited;
    AnsiString      m_Nom;
    AnsiString      m_Donnee;
    Type_Champ      m_fType;
    Type_Calcul     m_fTypeCalcul;
    Type_Calcul_Col m_fTypeCalculCol;
    AnsiString      m_RuptureAssociee;
    bool            m_bInitialise;
    virtual AnsiString __fastcall GetTexte( )const;
    void   __fastcall SetTexte( const AnsiString &Texte);
    void   __fastcall SetNom( const AnsiString &Nom)                            {if( Nom != m_Nom)                          { m_Nom = Nom;               Modifie( );} };
    void   __fastcall SetDonnee( const AnsiString &Donnee)                      {if( Donnee != m_Donnee)                    { m_Donnee = Donnee;         Modifie( );} };
    void   __fastcall SetType( Type_Champ Type)                                 {if( Type != m_fType)                       { m_fType = Type;            Modifie( );} };
    void   __fastcall SetTypeCalc( Type_Calcul Type)                            {if( Type != m_fTypeCalcul)                 { m_fTypeCalcul = Type;      Modifie( );} };
    void   __fastcall SetTypeCalcCol( Type_Calcul_Col Type)                     {if( Type != m_fTypeCalculCol)              { m_fTypeCalculCol = Type;   Modifie( );} };
    void   __fastcall SetRuptureAssociee( const AnsiString &RuptureAssociee)    {if( RuptureAssociee != m_RuptureAssociee)  { m_RuptureAssociee = RuptureAssociee;         Modifie( );} };
    void   __fastcall SetVisible( bool bVisible);
    void   __fastcall FormateValeur( );

public    :
    virtual __fastcall ~TCpChamp( );
    __fastcall TCpChamp( TListOfComposants *ListCp, TFlux *f, Carac_Composant CaracCp = Carac_Champ);
    __fastcall TCpChamp( TListOfComposants *ListCp, const TCoordonnee &X, const TCoordonnee &Y, Carac_Composant CaracCp = Carac_Champ);

    virtual void __fastcall Enregistre( TFlux *f)const;
    virtual void __fastcall Dessine( const TBande* b);
    virtual void __fastcall OnBeginEdit( TWinControl *aOwner, int OffsetX, int OffsetY) {};
    virtual void __fastcall OnEndEdit( ) {};
    virtual void __fastcall Nettoie( );
    virtual void __fastcall Calculs( );
    void         __fastcall InitValeur( bool bCalcAll = false);

    __property   AnsiString         Nom              = { read=m_Nom,             write=SetNom};
    __property   Type_Champ         Type             = { read=m_fType,           write=SetType};
    __property   AnsiString         Champ            = { read=m_Donnee,          write=SetDonnee};
    __property   AnsiString         Formule          = { read=m_Donnee,          write=SetDonnee};
    __property   Type_Calcul        TypeCalcul       = { read=m_fTypeCalcul,     write=SetTypeCalc};
    __property   Type_Calcul_Col    TypeCalculCol    = { read=m_fTypeCalculCol,  write=SetTypeCalcCol};
    __property   AnsiString         RuptureAssociee  = { read=m_RuptureAssociee, write=SetRuptureAssociee};
    __property   bool               Visible          = { read=m_bVisible,        write=SetVisible};
    __property   bool               Initialise       = { read=m_bInitialise,     write=m_bInitialise};
    __property   AnsiString         Texte            = { read=GetTexte,          write=SetTexte};
};
//---------------------------------------------------------------------------
class ETATAPI TCpImage : public TCpRectangle
{
protected :
    AnsiString          m_File;
    Type_Etirement      m_fEtirement;
    Graphics::TPicture *m_Picture;
    bool                m_Transparent;

    void __fastcall SetFile( const AnsiString &File)  {if( File != m_File)       { m_File = File;       Modifie( );} };
    void __fastcall SetPicture( TPicture *Picture)    {if( Picture != m_Picture) { m_Picture = Picture; Modifie( );} };
    void __fastcall SetEtirement( Type_Etirement f)   {if( f    != m_fEtirement) { m_fEtirement = f;    Modifie( );} };
    bool __fastcall GetStockageInterne( )const        {return (m_Picture != NULL);};
    void __fastcall SetTransparent( bool Transparent)  {if( Transparent != m_Transparent) { m_Transparent = Transparent;  Modifie( );} };
public    :
    __fastcall TCpImage( TListOfComposants *ListCp, TFlux *f, Carac_Composant CaracCp = Carac_Image);
    __fastcall TCpImage( TListOfComposants *ListCp, const TCoordonnee &X, const TCoordonnee &Y, Carac_Composant CaracCp = Carac_Image);
    virtual __fastcall ~TCpImage();

    virtual void __fastcall Enregistre( TFlux *f)const;
    virtual void __fastcall Dessine( const TBande* b);
    virtual void __fastcall InvalidateR( const TCoorRect &Rc);
    __property   AnsiString     File             = { read=m_File,            write=SetFile};
    __property   TPicture      *Picture          = { read=m_Picture,         write=SetPicture};
    __property   Type_Etirement Etirement        = { read=m_fEtirement,      write=SetEtirement};
    __property   bool           StockageInterne  = { read=GetStockageInterne };
    __property   bool           Transparent      = { read=m_Transparent,     write=SetTransparent};

};
//---------------------------------------------------------------------------
class ETATAPI TCpFleche : public TComposant
{
protected :
    TCoordonnee    m_LargeurPointe;
    TCoordonnee    m_HauteurPointe;
    TCoordonnee    m_Epaisseur;
    int            m_Orientation;

    void __fastcall SetLargeurPointe( const TCoordonnee &n) { if( n    != m_LargeurPointe) { m_LargeurPointe = n; Modifie( );} };
    void __fastcall SetHauteurPointe( const TCoordonnee &n) { if( n    != m_HauteurPointe) { m_HauteurPointe = n; Modifie( );} };
    void __fastcall SetEpaisseur(     const TCoordonnee &n) { if( n    != m_Epaisseur)     { m_Epaisseur = n; Modifie( );} };
    void __fastcall SetOrientation(   int         n)        { if( n    != m_Orientation)   { m_Orientation = n; Modifie( );} };
public    :
    __fastcall TCpFleche( TListOfComposants *ListCp, TFlux *f, Carac_Composant CaracCp = Carac_Fleche);
    __fastcall TCpFleche( TListOfComposants *ListCp, const TCoordonnee &X, const TCoordonnee &Y, Carac_Composant CaracCp = Carac_Fleche);

    virtual void __fastcall Enregistre( TFlux *f)const;
    virtual void __fastcall Dessine( const TBande* b);
    virtual void __fastcall InvalidateR( const TCoorRect &Rc);
    __property   TCoordonnee  LargeurPointe  = { read=m_LargeurPointe,   write=SetLargeurPointe};
    __property   TCoordonnee  HauteurPointe  = { read=m_HauteurPointe,   write=SetHauteurPointe};
    __property   int          Orientation    = { read=m_Orientation,     write=SetOrientation};
    __property   TCoordonnee  Epaisseur      = { read=m_Epaisseur,       write=SetEpaisseur};
};
//---------------------------------------------------------------------------
class ETATAPI TCpTableau : public TCpRectangle
{
protected :
    virtual bool   __fastcall GetVisible( )const;
private :
    typedef TCpRectangle inherited;
    bool            m_bInitialized, m_bEnCours;
    AnsiString      m_Nom;
    TList           *m_Colonnes, *m_Lignes;
    float           m_PenWidthLine;
    void   __fastcall SetNom( const AnsiString &Nom)  {if( Nom != m_Nom)            { m_Nom = Nom;          Modifie( );} };
    void   __fastcall SetVisible( bool Visible)       {if( Visible != m_bVisible)    { m_bVisible = Visible;  Modifie( );} };
    void   __fastcall SetPenWidthLine( float w)       {if( w     != m_PenWidthLine) { m_PenWidthLine = w;   Modifie();} };
    void   __fastcall SetNbLignes( short s);
    short  __fastcall GetNbLignes( )                  { return  (short)m_Lignes->Count;}

public    :
    virtual __fastcall ~TCpTableau( );
    __fastcall TCpTableau( TListOfComposants *ListCp, TFlux *f, Carac_Composant CaracCp = Carac_Tableau);
    __fastcall TCpTableau( TListOfComposants *ListCp, const TCoordonnee &X, const TCoordonnee &Y, Carac_Composant CaracCp = Carac_Tableau);

    virtual void __fastcall Enregistre( TFlux *f)const;
    virtual void __fastcall Calculs( );
            void __fastcall ReCalculColonnesLignes( const TCoorRect &CoorRc);
    virtual void __fastcall Dessine( const TBande* b);
    virtual void __fastcall Nettoie( );
    void         __fastcall InitValeur( bool bCalcAll = false);

    void         __fastcall AddColonne( const TCoordonnee &LargeurSaisie, const TCoordonnee &LargeurMin, const TCoordonnee &LargeurMax);
    COLONNE*     __fastcall GetColonne( short index, bool bRecalcul = true)const;
    short        __fastcall GetColonneCount( )const;
    TCoordonnee  __fastcall GetGaucheColonne( short index, bool ForceCanvasResol = true)const;
    TCoordonnee  __fastcall GetDroiteColonne( short index, bool ForceCanvasResol = true)const;
    void         __fastcall ColonnesClear();
    virtual TCoorRect __fastcall GetTrueCoordonnees( TCoorRect &Rc, const TBande* BandeADessiner=NULL)const{ return inherited::GetTrueCoordonnees( Rc, BandeADessiner);};
    virtual void      __fastcall GetTrueCoordonnees( TCoorPoint &ptHtG, TCoorPoint &ptBsD, const TBande* BandeADessiner=NULL)const;

    void         __fastcall GetLigne( short index, TCoordonnee &cHaut, TCoordonnee &cbas)const;
    void         __fastcall LignesClear();

    __property   AnsiString Nom             = { read=m_Nom,             write=SetNom};
    __property   bool       Visible         = { read=m_bVisible,         write=SetVisible};
    __property   short      ColonnesCount   = { read=GetColonneCount};
    __property   float      PenWidthLine    = { read=m_PenWidthLine,    write=SetPenWidthLine };
    __property   short      NbLignes        = { read=GetNbLignes,   write=SetNbLignes };


};
//---------------------------------------------------------------------------
#endif

